#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PLL pair<ll,ll>
const ll N=1e8+10;
ll n,m,x;
int main(){
	freopen("arena.in","r",stdin);
	freopen("arena.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	srand(time(0));
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		cin>>x;
	}
	for(ll i=1;i<=m;i++){
		cin>>x;
	}
	string s;
	ll rows=ceil(log2(n));
	for(ll i=1;i<=rows;i++){
		cin>>s;
	}
	ll t;
	cin>>t;
	ll x=1;
	while(rows--){
		x*=2;
	}
	while(t--){
		cout<<rand()%x<<"\n";
	}
	return 0;
}